﻿function myAjax(url,data,onSuccess) {
    $.ajax({
        url: url,
        data: data,
        dataType: "json",
        type: "POST",
        async: false,
        success: function (result) {
			onSuccess(result);
        }
    });
}



function getParmeterOfObj(obj) {
    var objArray=[];
    for(var key in obj) {
        var s=key+"="+obj[key];
        objArray.push(s);
    }
    var parmeter=objArray.join("&"); 
    return parmeter;       
}

function getUrlParam(paramName) {
    var url = window.location.href;
    var oRegex = new RegExp('[\?&]' + paramName + '=([^&]+)', 'i');
    var oMatch = oRegex.exec(url);
    if (oMatch && oMatch.length > 1) {
        return decodeURI(oMatch[1]);
    } else {
        return "";
    }
}
function setUrlParam(name, value) {
    var reg = new RegExp("(\\?|&)" + name + "=([^&]*)(?=&|$)");
    var r = window.location.href.match(reg);
    if (r != null) {
        window.location.href = window.location.href.replace(reg, r[1] + name + "=" + escape(value));
    }
    else {
        var url = window.location.href;
        if (window.location.href.indexOf("?") < 0) {
            url += "?";
        }
        else {
            url += "&";
        }
        url += name + "=" + escape(value);
        window.location.href = url;
    }
}
function changePageStyle(url) {
    var mycss;
    if (isIE()) {
        document.createStyleSheet(url);
    }
    else {
        $("head").append("<link href=\"" + url + "\" rel=\"stylesheet\" type=\"text/css\" />");
    }
}
function isIE() {
    var Ka = navigator.userAgent.toLowerCase();
    var rt = Ka.indexOf("opera") != -1;
    var r = Ka.indexOf("msie") != -1 && (document.all && !rt);
    return r;
}

//加载样式内容
function loadStyle(styleText) {
    var s = document.createElement("style");
    s.type = "text/css";
    try {//IE
        s.styleSheet.cssText = styleText;
    } catch (e) {//FF Chrome
        s.appendChild(document.createTextNode(styleText));
    }
    document.getElementsByTagName("head")[0].appendChild(s);
}

//加载样式文件
function loadStyleFile(url) {
    var s = document.createElement("link");
    s.href = url;
    s.type = "text/css";
    s.rel = "stylesheet";
    document.getElementsByTagName("head")[0].appendChild(s);
}


function getClientHeight() {
    var clientHeight = document.body.clientHeight; //其它浏览器默认值
    if (navigator.userAgent.indexOf("MSIE 6.0") != -1) {
        clientHeight = document.body.clientHeight;
    }
    else if (navigator.userAgent.indexOf("MSIE") != -1) {//IE7 IE8
        clientHeight = document.documentElement.offsetHeight
    }
    if (navigator.userAgent.indexOf("Chrome") != -1) {
        clientHeight = document.body.scrollHeight;
    }
    if (navigator.userAgent.indexOf("Firefox") != -1) {
        clientHeight = document.documentElement.scrollHeight;
    }
    return clientHeight;
}
function addAttribute(rows) {
    for (var index = 0; index < rows.length; index++) {
        var obj = new Object();
        for (var o in rows[index]) {
            obj[o] = rows[index][o];
        }
        rows[index]["attributes"] = obj;
        if ((rows[index].children != undefined) && (rows[index].children.length > 0)) {
            addAttribute(rows[index].children);
        }
    }
    return rows;
}

function convertToTreeData(data, idField, nameField, childrenField, boundCallback, curentLevel, levelLimit,parent) {
    levelLimit = levelLimit >= 0 ? levelLimit : null;
    curentLevel = curentLevel;
    if (data) {
        var nodes = [];
        for (var i = 0; i < data.length; i++) {
            var row = data[i];
            var node = { "id": row[idField], "text": row[nameField], attributes: row };
            if ($.isFunction(boundCallback)) {
                if (boundCallback(node, row, parent) != false) {
                    nodes.push(node);
                }
            }
            else {
                nodes.push(node);
            }
            var mark = true;
            var level = curentLevel + 1;

            if (levelLimit != null) {
                if (level > levelLimit) {
                    mark = false;
                    var children = row[childrenField];
                    if (children && children.length > 0) {
                        node.state = "closed";
                    }
                }
            }
            if (mark) {
                var children = row[childrenField];
                if (children && children.length > 0) {
                    var childrenNodes = convertToTreeData(children, idField, nameField, childrenField, boundCallback, level, levelLimit, row);
                    if (childrenNodes) {
                        node.children = childrenNodes;
                    }
                }
            }
        }
        return nodes;
    }
    return null;
}


function disable(index) {
    $("a.easyui-linkbutton").each(function (_index) {
        if (index.indexOf(_index) != -1) {
            $(this).linkbutton('disable');
        } else {
            $(this).linkbutton('enable');
        }
    });
}
function showButton(index) {
    $("a.easyui-linkbutton").each(function (_index) {
        if (index.indexOf(_index) != -1) {
            $(this).show();
        }
    });
}
function linkButtonsDisable(buttonsName, panel) {
    panel.find("a.easyui-linkbutton").each(function () {
        var button = $(this);
        var text = button.find(".l-btn-text");
        if ($.inArray(text.text(), buttonsName) >= 0) {
            button.linkbutton('disable');
        }
        else {
            button.linkbutton('enable');
        }
    });
}
function linkButtonsHidden(buttonsName, panel) {
    panel.find("a.easyui-linkbutton").each(function () {
        var button = $(this);
        var text = button.find(".l-btn-text");
        if ($.inArray(text.text(), buttonsName) >= 0) {
            button.hide();
        }
        else {
            button.show();
        }
    });
}
function toolbarsDisable(buttonsName, datagrid) {
    var panel = datagrid ? datagrid.datagrid("getPanel") : null;
    var el = panel || $(document);
    var toolbar = el.find(".datagrid-toolbar");
    var buttons = toolbar.find(".l-btn");
    buttons.each(function (_index) {
        var button = $(this);
        var text = button.find(".l-btn-text");
        if ($.inArray(text.text(), buttonsName) >= 0) {
            button.linkbutton('disable');
        }
        else {
            button.linkbutton('enable');
        }
    });
}
//提交请求
function createRequest(path, content, requestformat, responseformat, options, expro) {
    requestformat = requestformat || 'JSON';
    responseformat = responseformat || 'JSON';
    content = content || '';
    var d = content;
    var b = "";
    var isCache = false;
    var isHead = true;
    if (options) {
        if (typeof (options) == "object") {
            isCache = options.isCache || false;
            isHead = options.isHead != false ? true : false;
        }
        else {
            isCache = true;
        }
    }
    if (isCache) {
        b = "<Cache type='MEMORY' period='6000000000000'></Cache>";
    }

    if (typeof (content) == "string" && content.indexOf("<Data>") < 0) {
        if (requestformat == "JSON") {
            var data = $("<Data></Data>").text(content);
            content = data.html();
        }
        d = "<Data>" + content + "</Data>";
    }

    expro = expro ? 'exinfo="' + expro + '" ' : '';

    var request = '<Request action="' + path + '" request="' + requestformat + '" response="' + responseformat + '" ' + (!isHead ? 'nohead="true"' : '') + expro + '>' + b + d + '</Request>';
    return request;
}

//打开对话框
// width:宽度
// height:高度
// top：y轴位置
// left:x轴位置
// iconCls：图标
// title：文字
// url：地址
//dialogMaxabled:是否可以最大化
//isClose:是否显示关闭按钮
// isFrame:是否以FRAME加载
// contentHtml 对话框内容
// overflow:是否有滚动条
// buttons：按钮
// cancelButton：是否有取消按钮
// close：关闭对话框的执行事件
// dialogArgs:参数
function OpenDialog(option) {
    var w = option.width;
    var h = option.height;
    var top = option.top || 0;
    var left = option.left || 0;
    var iconCls = option.iconCls;
    var title = option.title;
    var url = option.url || "";
    var minimizable = option.minimizable || false;
    var isFrame = option.isFrame;
    var contentHtml = option.contentHtml || "";
    var overflow = option.overflow || false;
    var buttons = option.buttons || [];
    var padding = isNaN(option.padding) ? 4 : option.padding;
    var cancelButton = option.cancelButton;
    var isClose = option.isClose != false ? true : false;
    var close = option.close;
    var dialogArgs = option.dialogArgs;
    var dialogArgs2 = option.dialogArgs2;
    var windowLevel = option.windowLevel;
    var opener = option.opener||window.self;
    var modal = option.modal == false ? false : true;
    var resizable = option.resizable == false ? false : true;
    var maximized = option.maximized;
    var draggable = option.draggable;
    //var dialog = $("#divDialog");
    //if (dialog.length <= 0) {
    //    var win = window.self;
    //    if (windowLevel) {
    //        win = window[windowLevel];
    //    }
    var body = $("body");
    var dialog = $("<div dialog='1' style='overflow-y:" + (overflow ? "auto" : "hidden") + "' />").appendTo(body);
    //}
    if (cancelButton != false) {
        buttons.push({ text: '取  消',
            iconCls: 'icon-cancel',
            handler: function () {
                dialog.dialog("close");
            }
        });
    }
    var options = {
        title: title,
        iconCls: iconCls,
        width: w,
        height: h,
        modal: modal,
        resizable: resizable,
        maximizable: minimizable,
        maximized: maximized,
        draggable: draggable,
        closable: isClose,
        overflow: overflow,
        onBeforeOpen: function () {
            var content = dialog.find(".dialog-content");
            if (!isFrame) {
                if (url != "") {
                    content.load(url);
                }
                else if (contentHtml != "") {
                    content.html(contentHtml);
                }
            }
            else {
                content.html("");
                var frame = $("<iframe frameborder='0' scrolling='no' width='100%' height='100%' src='" + url + "'></iframe>").appendTo(content);
                //frame.data("dialogArgs", dialogArgs);
                frame.get(0).dialogArgs = dialogArgs;
                frame.get(0).dialogArgs2 = dialogArgs2;
                frame.get(0).closeDialog = function () { dialog.dialog("close") };
                frame.get(0).opener = opener;
                var win = frame.get(0).contentWindow;
                if (win) {
                    try {
                        win.dialogArgs = dialogArgs;
                    }
                    catch (ex) { }
                }
            }
        },
        onBeforeClose: function () {
            var content = dialog.find(".dialog-content");
            if ($.isFunction(option.close)) {
                option.close();
            }
            content.html("");
        },
        onClose: function () {
            dialog.dialog("destroy");
        }
    }
    if (option.top) {
        options.top = option.top;
    }
    if (option.left) {
        options.left = option.left;
    }
    if (buttons.length > 0) {
        options.buttons = buttons;
    }
    else {
        options.buttons = null;
    }
    dialog.dialog(options);
    return dialog;
}
function CloseDialog(obj) {
    var dialog = null
    if (obj.hasClass("l-btn")) {
        var el = obj.parent();
        while (el.length > 0) {
            if (el.attr("dialog") == "1") {
                dialog = el;
                break;
            }
            else {
                el = el.parent();
            }
        }
    }
    else if (el.attr("dialog") == "1") {
        dialog = obj;
    }
    dialog.dialog("close");
}


//读取服务器数据
function getServerData(obj, url, async, callback, requestFormat, responseFormat, options) {
    async = async || false;
    var context = obj;
    requestFormat = requestFormat || "JSON";
    responseFormat = responseFormat || "JSON";
    if (requestFormat.toLowerCase() == "json" && obj) {
        context = JSON.stringify(obj);
    }
    var requestStr = createRequest(url, context, requestFormat, responseFormat, options);
    var data = null;
    $.ajax({
        url: __GlobalInfo.postUrl,
        dataType: "json",
        type: "POST",
        async: async,
        data: requestStr,
        success: function (response) {
            var result = response.Result;
            if (result.Success) {
                if (callback) {
                    callback(result.Data);
                }
                data = result.Data;
            }
            else {
                alert("出现错误");
            }
        },
        error: function (xmlhttp) {
            //alert("格式错误")
        }
    });
    return data;
}

//提交数据到服务器
function postServer(obj, url, async, requestFormat, responseFormat) {
    async = async || false;
    var context = obj;
    requestFormat = requestFormat || "JSON";
    responseFormat = responseFormat || "JSON";
    if (requestFormat.toLowerCase() == "json" && obj) {
        context = JSON.stringify(obj);
    }
    var requestStr = createRequest(url, context, requestFormat, responseFormat);
    var success = false;
    $.ajax({
        url: __GlobalInfo.postUrl,
        dataType: "json",
        type: "POST",
        async: async,
        data: requestStr,
        success: function (response) {
            var result = response.Result;
            if (result.Success) {
                success = true;
            }
            else {
                success = false;
            }
        },
        error: function (xmlhttp) {
            success = false;
        }
    });
    return success;
}

//提交并返回数据
function postReturnData(obj, url, requestFormat, responseFormat) {
    var async = false
    var context = obj;
    requestFormat = requestFormat || "JSON";
    responseFormat = responseFormat || "JSON";
    if (requestFormat.toLowerCase() == "json" && obj) {
        context = JSON.stringify(obj);
    }
    var requestStr = createRequest(url, context, requestFormat, responseFormat);
    var data = null;
    $.ajax({
        url: __GlobalInfo.postUrl,
        dataType: "json",
        type: "POST",
        async: async,
        data: requestStr,
        success: function (response) {
            var result = response.Result;
            if (result.Success) {
                if (result.Data) {
                    data = result.Data;
                }
                else {
                    data = result.Success;
                }
            }
            else {
                alert("出现错误");
            }
        },
        error: function (xmlhttp) {
        }
    });
    return data;
}

//解析数据
function analysisData(data) {
    var getSplit = function (rows) {
        var number = [0, 0, 0];
        var splits = ["\t", ",", " "];
        for (var index = 0; index < 10; index++) {
            if (index >= rows.length) {
                break;
            }
            var d = rows[index];
            if (d != "") {
                for (var num in splits) {
                    if (d.indexOf(splits[num]) > -1) {
                        number[num] = number[num] + 1;
                    }
                }
            }
        }
        var num = 0;
        for (var index = 0; index < number.length - 1; index++) {
            if (number[index] < number[index + 1]) {
                num = (index + 1);
            }
        }
        return splits[num];
    };
    var rows = [];
    if (data.length == 0) {
        return rows;
    }
    //获取每行数据
    var _rows = data.split('\n');
    if (_rows.length == 0) {
        return rows;
    }
    var split = getSplit(_rows);
    for (var index = 0; index < _rows.length; index++) {
        if (_rows[index] == "") {
            continue;
        }
        rows.push(_rows[index].split(split));
    }
    return rows;
}


function setClipboard(maintext) {
    if (window.clipboardData) {
        return (window.clipboardData.setData("Text", maintext));
    }
    else if (window.netscape) {
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = maintext;
        str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip) return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
        return true;
    }
    return false;
}
function getClipboard() {
    if (window.clipboardData) {
        return (window.clipboardData.getData('Text'));
    }
    else if (window.netscape) {
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;
        trans.addDataFlavor('text/unicode');
        clip.getData(trans, clip.kGlobalClipboard);
        var str = new Object();
        var len = new Object();
        try {
            trans.getTransferData('text/unicode', str, len);
        }
        catch (error) {
            return null;
        }
        if (str) {
            if (Components.interfaces.nsISupportsWString) str = str.value.QueryInterface(Components.interfaces.nsISupportsWString);
            else if (Components.interfaces.nsISupportsString) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
            else str = null;
        }
        if (str) {
            return (str.data.substring(0, len.value / 2));
        }
    }
    return null;
}

function layoutResize(layout) {
    layout = layout || $("body");
    $("body").layout("resize");
}

function layoutChildResize(layout, region, el) {
    var el = !$.isArray(el) ? [el] : el;
    var panel = layout.layout("panel", region);
    panel.panel({
        "onResize": function () {
            for (var i = 0; i < el.length; i++) {
                var e = el[i];
                e.width(panel.innerWidth()).height(panel.innerHeight());
                if ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0")) {
                    if (e.get(0).id) {
                        var win = document.frames[e.get(0).id];
                        if (win) {
                            if (win.layoutResize) {
                                win.layoutResize();
                            }
                        }
                    }
                }
            }
        }
    });
    layout.layout("resize");
}

//过滤TREE数据
function filterTree(node, callback, pnode) {
    var n = $.extend(true, {}, node);
    var children = node.children;
    if (children && children.length > 0) {
        var mark = false;
        n.children = [];
        if (callback) {
            mark = callback(n, pnode);
        }
        for (var i = 0; i < children.length; i++) {
            var v = children[i];
            var result = filterTree(v, callback, node);
            if (result) {
                n.children = n.children || [];
                n.children.push(result);
                mark = true;
            }
        }
        if (mark) {
            return n;
        }
    }
    else {
        if (callback) {
            if (callback(n, pnode)) {
                return n;
            }
        }
    }
}

//检索树结构数据
function queryTreeData(text, node, tree) {
    var n = $.extend(true, {}, node);
    if (n.text.indexOf(text) >= 0) {
        return n;
    }
    else {
        n.children = [];
        var children = node.children;
        var mark = false;
        if (children && children.length > 0) {
            for (var i = 0; i < children.length; i++) {
                var v = children[i];
                var result = queryTreeData(text, v, n, tree);
                if (result) {
                    n.children.push(result);
                    mark = true;
                }
            }
        }
        if (mark) {
            return n;
        }
        else {
            return null;
        }
    }
}

//清空所有树控件节点选中状态
function allTreeNodeUnChecked(tree) {
    var root = tree.tree("getRoots");
    $.loop(root, function (v, i) {
        tree.tree("uncheck", v.target);
        var nodes = tree.tree("getChildren", v.target);
        $.loop(nodes, function (v, i) {
            if (v.checked) {
                tree.tree("uncheck", v.target);
            }
        });
    });
}

//执行FRAME中的方法
function execFrameFunction(frame, fnname, args) {
    if (frame.jquery) {
        frame = frame.get(0);
    }
    var win = frame.contentWindow;
    if ($.isFunction(win[fnname])) {
        args = args || [];
        return win[fnname].apply(null, args);
    }
}

Date.prototype.format = function (format) {
    var o = {
        "M+": this.getMonth() + 1, //month 
        "d+": this.getDate(), //day 
        "h+": this.getHours(), //hour 
        "m+": this.getMinutes(), //minute 
        "s+": this.getSeconds(), //second 
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter 
        "S": this.getMilliseconds() //millisecond 
    }

    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }

    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}


Date.prototype.getMonthWeek = function () {
    var offset = this.getDay();
    if (offset == 0) {
        offset = -6;
    }
    else {
        offset = (offset - 1) * -1;
    }
    sd = new Date(this.getFullYear(), this.getMonth(), this.getDate() + offset);
    ed = new Date(sd.getFullYear(), sd.getMonth(), sd.getDate() + 6);
    return Math.ceil(parseInt(ed.format("dd")) / 7);
};

String.prototype.endWith = function (s) {
    if (s == null || s == "" || this.length == 0 || s.length > this.length)
        return false;
    if (this.substring(this.length - s.length) == s)
        return true;
    else
        return false;
    return true;
}

String.prototype.startWith = function (s) {
    if (s == null || s == "" || this.length == 0 || s.length > this.length)
        return false;
    if (this.substr(0, s.length) == s)
        return true;
    else
        return false;
    return true;
}

String.prototype.formatForXml = function () {
    return this.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
}

$.formatForXml = function (params) {
    if (typeof (params) == "string") {
        params = params.formatForXml();
    } else {
        for (var key in params) {
            params[key] = params[key].formatForXml();
        }
    }
    return params;
}

$.formatUserName = function (name) {
    return name;
    //    if (typeof (name) != "undefined" && name.length > 0) {
    //        return "*" + name.substring(1);
    //    }
    //    return "";
}

//重写toFixed方法
Number.prototype.toFixed = function (len) {
    len = len ? len : 0;
    var t = Math.pow(10, len);
    var num = this * t;
    num = Math.round(num) / t;
    num = num.toString();
    var i = num.indexOf(".");
    var l = len;
    var temp = "";
    if (i >= 0) {
        temp = num.substr(i + 1);
    }
    else {
        if (l > 0) {
            num += ".";
            temp = "";
        }
    }
    l = l - temp.length;
    for (var n = 0; n < l; n++) {
        num += "0";
    }
    return num;
}

$.fn.serializeToObject = function () {
    var array = this.find("*[name]").serializeArray();
    var obj = {};
    for (var i = 0; i < array.length; i++) {
        obj[array[i].name] = array[i].value;
    }
    return obj;
}


//获取当前页码起始编号和末尾编号
$.getMinToMaxByPageNumber = function(pageNumber,pageSize){
    var p = pageNumber - 1;
    var min = p * pageSize + 1;
    var max = min + pageSize - 1;
    return { "min": min, "max": max };
}


$.loadXml = function (initXmlPath) {
    var xml = "";
    $.ajax({
        "url": initXmlPath,
        "type": "GET",
        "dataType": "text",
        "async": false,
        "success": function (result) {
            xml = result;
        }
    });
    return xml;
}


var __htmlEncodeElement = null;
function htmlEnCode(text) {
    if (!__htmlEncodeElement) {
        __htmlEncodeElement = $("<DATA></DATA>");
    }
    __htmlEncodeElement.html("");
    __htmlEncodeElement.text(text);
    return __htmlEncodeElement.html();
}
function objectToXml(obj, tagName, AttributePrefix) {
    var xml = "";
    var beginTag = "<" + tagName + "{0}>";
    var property = [];
    var innerText="";
    for (var k in obj) {
        if (k == "text") {
            innerText = "<![CDATA[" + obj[k] + "]]>";
        }
        else {
            if (obj[k] && typeof (obj[k]) == "object") {
                if (obj[k].jquery || $.isFunction(obj[k])) {
                    continue;
                }
                if ($.isArray(obj[k])) {
                    for (var i = 0; i < obj[k].length; i++) {
                        xml += objectToXml(obj[k][i], k);
                    }
                }
                else {
                    xml += objectToXml(obj[k], k, AttributePrefix);
                }
            }
            else {
                var n = k;
                if (AttributePrefix) {
                    if (n.indexOf(AttributePrefix) == 0) {
                        n=n.replace(AttributePrefix, "");
                    }
                }
                property.push(n + "=\"" + (htmlEnCode(obj[k]) || "") + "\"");
            }
        }
    }
    var p = property.length > 0 ? " " + (property.join(" ")) : "";
    beginTag = beginTag.replace(/\{\d+\}/, p);
    var endTag = "</" + tagName + ">";
    xml = beginTag + innerText + xml + endTag;
    return xml;
}

function xmlToObject(xml, AttributePrefix) {
    //xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + xml;
    var obj={};
    var xmldoc = $.parseXML(xml);
    xmldoc = $(xmldoc);
    var root = xmldoc.children();
    var rootName="";
    for (var i = 0; i < root.length; i++) {
        var n = root[i];
        rootName = n.tagName;
        fn(n,obj);
    }
    function fn(node,curObject) {
        var tag = node.tagName;
        var nobj = null;
        if (!curObject[tag]) {
            curObject[tag] = nobj = {};
        }
        else {
            if (!$.isArray(curObject[tag])) {
                curObject[tag] = [curObject[tag]];
            }
            nobj = {};
            curObject[tag].push(nobj);
        }
        var attributes = node.attributes;
        for (var i = 0; i < attributes.length; i++) {
            var attr = attributes[i];
            var name = AttributePrefix ? AttributePrefix + attr.name : attr.name;
            var value = attr.nodeValue;
            if (attr.nodeValue == "false") {
                value = false;
            }
            else if (attr.nodeValue == "true") {
                value = true;
            }
            else {
                value = attr.nodeValue;
            }
            nobj[attr.name] = value;
        }
        if (node.hasChildNodes()) {
            var children = node.childNodes;
            for (var i = 0; i < children.length; i++) {
                var c = children[i];
                if (c.nodeType == 3) {
                    nobj.text = c.nodeValue;
                }
                else if (c.nodeType == 4) {
                    nobj.text = c.wholeText;
                }
                else {
                    fn(c, nobj);
                }
            }
        }
    }
    return obj[rootName];
}

function getXmlObj(path) {
	var resultObj={};
    $.ajax({
        url: __GlobalInfo.webroot+"/"+path,
        data: null,
        dataType: "text",
        type: "POST",
        async: false,
        success: function (result) {
            if(result) {
            	resultObj=xmlToObject(result);
            }
        }
    })	  
    return resultObj;  
}


